let fn = async ({name, public}, { socket, io, reg, user, NOTIFY, ROOMS }, topic) => {
    try {
        if (!user.perm.includes('create_room')) {
            socket.emit(NOTIFY, { data: `无权创建房间` })
        } else {
            await reg.rooms.newRoom(name, user, public)
            socket.emit(NOTIFY, { data: `${user.alias} 创建房间 ${name}` })
            let rooms = await reg.rooms.list()
            io.emit(ROOMS, await rooms)
        }
    } catch ({ message }) {
        socket.emit(NOTIFY, { topic, data: message })
    }
}

module.exports = fn